package personal.wang.juc;

import java.util.concurrent.Callable;
import java.util.function.*;

public class LambdTest {
    public static void main(String[] args) {
        Consumer<String> consumer = (x) -> {
            System.out.println(x);
        };
        consumer.accept("aa");

        Function<String , Integer> function = (x) -> {
            return Integer.parseInt(x);
        };
        System.out.println(function.apply("1") instanceof Integer);
        BiConsumer<String, Integer> biConsumer = (x , y) -> {
            System.out.println(Integer.parseInt(x) + y );
        };
        biConsumer.accept("1" , 2);
        BiFunction<String , String , Integer> biFunction = (x , y) -> {
            return Integer.parseInt(x) + Integer.parseInt(y);
        };
        System.out.println(biFunction.apply("1", "5"));
        Supplier<Integer> supplier = () ->{
           return 1 ;
        };
        System.out.println(supplier.get());
        Callable<Integer> callable = () ->{
            return 2 ;
        };
        try {
            System.out.println(callable.call());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        Runnable r = () -> {
            System.out.println("runnable");
        };
        r.run();
        Runnable rr = LambdTest::new ;
        rr.run();
    }
    public LambdTest(){
        System.out.println("constructor");
    }
}
